//import Vue from 'vue'
import App from './App.vue'
import router from './router'

//引入 elementUI
//import ElementUI from 'element-ui'
//import 'element-ui/lib/theme-chalk/index.css'

//import Vuex from 'vuex'

//cookies
import VueCookies from 'vue-cookies'

//图表
//import echarts from 'echarts'

//重写弹出框，避免多次弹出提示
import { message } from './utils/ResetMessage'

/*********************自定义**************************/
// 全局Request
import Request from './utils/Request'
//图标
import '../public/icon/iconfont.css'

//常用组件
import Dialog from './components/common/Dialog'
import Table from './components/common/Table'

import Verify from './utils/Verify'

Vue.prototype.$echarts = echarts

Vue.config.productionTip = false

Vue.use(VueCookies)

Vue.use(ELEMENT)

//Vue.use(Vuex)

Vue.component('Dialog', Dialog)
Vue.component('Table', Table)

Vue.prototype.Verify = Verify
Vue.prototype.$message = message
Vue.prototype.Request = Request
Vue.prototype.global = {
  //搜索，新增 默认高度
  topPanelHeight: 35,
  //顶部高度
  topHeight: 60,
  //内容padding
  padding: 10,
  //分页高度
  paginationHeight: 50,
  //顶部tab
  topTabHeight: 40,
  //padding高度
  extHeight: 10 + 12,
}
Vue.prototype.getTableHeight = function(height) {
  let tableHeight =
    window.innerHeight -
    this.global.topHeight -
    this.global.topTabHeight -
    this.global.padding * 2 -
    this.global.paginationHeight -
    height -
    this.global.extHeight
  return tableHeight
}

const store = new Vuex.Store({
  state: {},
  mutations: {
    //es6语法，等同edit:funcion(){...}
  },
})

//权限 has 指令

Vue.directive('has', {
  inserted: function(el, binding, vnode) {
    let userInfo = JSON.parse(sessionStorage.getItem('userInfo'))
    let permissionCodeList = userInfo.permissionCodeList
    permissionCodeList =
      permissionCodeList == undefined ? [] : permissionCodeList
    if (!permissionCodeList.includes(binding.value)) {
      el.parentNode.removeChild(el)
    }
  },
})

new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount('#app')
